package cn.linran.org.service.impl;

import cn.linran.basic.util.PageList;
import cn.linran.org.domain.Department;
import cn.linran.org.mapper.DepartmentMapper;
import cn.linran.org.query.DepartmentQuery;
import cn.linran.org.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Override
    public List<Department> loadAll() {
        return departmentMapper.loadAll();
    }

    @Override
    public Department selectById(Long id) {
        return departmentMapper.selectById(id);
    }

    @Override
    public void save(Department department) {
        departmentMapper.save(department);
    }

    @Override
    public void remove(Long id) {
        departmentMapper.remove(id);
    }

    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Override
    public PageList<Department> pageQuery(DepartmentQuery query) {
        Integer count=departmentMapper.queryCount(query);
        List<Department> rows = departmentMapper.queryData(query);
        return new PageList<>(count,rows);
    }

}
